using Microsoft.Extensions.DependencyInjection;
using ProductService.Application.Services;
using SharedKernel.Infrastructure.EventBus;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;

namespace ProductService.Application
{
    /// <summary>
    /// 应用层依赖注入配置
    /// </summary>
    public static class DependencyInjection
    {
        /// <summary>
        /// 添加应用服务
        /// </summary>
        /// <param name="services">服务集合</param>
        /// <returns>服务集合</returns>
        public static IServiceCollection AddApplication(this IServiceCollection services)
        {
            // 注册应用服务
            services.AddScoped<IProductAppService, ProductAppService>();

            // 注册事件总线
            services.AddEventBus();

            // 注册事件处理器
            services.AddEventHandlers(Assembly.GetExecutingAssembly());

            return services;
        }
    }
}